<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>调度计划</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <script src="/style/public/publicStyle.js"></script>


</head>

<body>
<div class="weadmin-nav">
			<span class="layui-breadcrumb" style="visibility: visible;">
			<a href="">任务管理</a><span lay-separator="">/</span>
			<a>
				<cite>调度计划</cite></a>
			</span>

</div>
<div class="layui-form">
    <div class="layui-form-item">
        <div class="layui-inline" style="top: 7px;">
            <label class="layui-form-label">日期范围</label>
            <div class="layui-inline" id="laydate">
                <div class="layui-input-inline">
                    <input type="text" autocomplete="off" id="startDate" class="layui-input" placeholder="开始日期">
                </div>
                <div class="layui-form-mid">-</div>
                <div class="layui-input-inline">
                    <input type="text" autocomplete="off" id="endDate" class="layui-input" placeholder="结束日期">
                </div>
            </div>
        </div>
        <button type="button" class="layui-btn layui-btn-radius" id="seach">查询</button>
    </div>
</div>
<div class="weadmin-body">
    <div class="layui-col-md3">
        <div class="layui-bg-gray" style="padding: 30px;">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card" style="width: 100%;">
                        <div class="layui-card-header" style="background-color: #476c88;color: #ffffff;">执行队列</div>
                        <div class="layui-panel" style="background-color: #fbfbfb;height: 260px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md9">
        <div class="layui-bg-gray" style="padding: 30px;">
            <div class="layui-row layui-col-space15" id="card">


            </div>
        </div>
    </div>
</div>

<div class="weadmin-body">
    <div class="layui-bg-gray" style="padding: 30px;">
        <div class="layui-row layui-col-space15" id="cards">
            <p style="margin: 0 0 10px;text-align: left;border-bottom: 1px solid #3864e5;color: gray;padding-bottom: 15px;">全部任务</p>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['dropdown', 'util', 'laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element'], function () {

        var html = "";
        var htmls = "";
        $.ajax({
            type: "get",
            url: " /jobinfo/pageList",
            async: true,
            data: {'page': 1, 'limit': 20},
            success: function (json) {
                var date;


                for (var i = 0; i < json.data.length; i++) {
                    var status = json.data[i].triggerStatus == 1 ? '  <font style="color: #00FF00;font-weight:bold;">运行中</font>' : '  <font style="color: #ff2d28;font-weight:bold;">停止</font>';
                    var triggerLastTime = 0;
                    var triggerNextTime = 0;
                    if (json.data[i].triggerLastTime != 0) {
                        date = new Date(json.data[i].triggerLastTime);
                        triggerLastTime = date.format("yyyy-MM-dd hh:mm:ss");
                    }
                    if (json.data[i].triggerLastTime != 0) {
                        date = new Date(json.data[i].triggerNextTime);
                        triggerNextTime = date.format("yyyy-MM-dd hh:mm:ss");
                    }
                    if (json.data[i].triggerStatus == 1) {
                        html = html + '<div class="layui-col-md3" id="' + i + '"><div class="layui-card"><div class="layui-card-header" style="background-color: #476c88;color: #ffffff;">' + json.data[i].executorHandler + '<span style="float: right;">状态：'+status+'</span></div><div class="layui-panel" style="height: 100px;background-color: #fbfbfb">上次执行时间：' + triggerLastTime + '<br>下次执行时间：' + triggerNextTime + '<br>JobHandler:' + json.data[i].jobDesc + '</div></div></div>';

                    }
                    htmls = htmls + '<div class="layui-col-md3" id="' + i + '"><div class="layui-card"><div class="layui-card-header" style="background-color: #476c88;color: #ffffff;">' + json.data[i].executorHandler + '<span style="float: right;">状态：'+status+'</span></div><div class="layui-panel" style="height: 100px;background-color: #fbfbfb">上次执行时间：' + triggerLastTime + '<br>下次执行时间：' + triggerNextTime + '<br>JobHandler:' + json.data[i].jobDesc + '</div></div></div>';
                }
                document.getElementById("card").innerHTML = html;
                document.getElementById("cards").innerHTML = htmls;
            }
        });


    })

    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,                 //月份   
            "d+": this.getDate(),                    //日
            "h+": this.getHours(),                   //小时   
            "m+": this.getMinutes(),                 //分   
            "s+": this.getSeconds(),                 //秒   
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
            "S": this.getMilliseconds()             //毫秒   
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };
</script>

</html>